<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c"%>
<%
	String path = request.getContextPath();
%>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>账户 新增</title>
<jsp:include page="../../import.jsp" flush="true"/>
</head>
<body>
		<form id="mcrPrpsRate_form">
            <div class="fieldset1 tabel_col tabel_col_s clearFix noBorder">
                <div class="fieldBox col_50">
                    <div class="label">客户类型</div>
                    <div class="field">
                        <select name="cstTypeCd" id="cstTypeCd">
                            <option value="0">内部</option>
                            <option value="1">外部</option>
                            <option value="2">物流</option>
                            <option value="3">首付贷</option>
                            <option value="4">车贷分期</option>
                        </select>
                    </div>
                </div>
                <div class="fieldBox col_50">
                    <div class="label">贷款类型</div>
                    <div class="field">
                        <select name="crTypCd" id="crTypCd">
                            <option value="1111">--全部--</option>
                            <option value="FQHK">分期还款</option>
                            <option value="SJSH">随借随还</option>
                        </select>
                    </div>
                </div>
                <div class="fieldBox col_50">
                    <div class="label">贷款期数</div>
                    <div class="field">
                        <select name="crPd" id="crPd">
                            <option value="1111">--全部--</option>
                            <option value="1">1</option>
                            <option value="2">2</option>
                            <option value="3">3</option>
                            <option value="4">4</option>
                            <option value="5">5</option>
                            <option value="6">6</option>
                            <option value="7">7</option>
                            <option value="8">8</option>
                            <option value="9">9</option>
                            <option value="10">10</option>
                            <option value="11">11</option>
                            <option value="12">12</option>
                        </select>
                    </div>
                </div>
                <div class="fieldBox col_50">
                    <div class="label">授信等级</div>
                    <div class="field">
                        <select name="crLvlCd" id="crLvlCd">
                            <option value="1111">--全部--</option>
                            <option value="group01">group01</option>
                            <option value="group02">group02</option>
                            <option value="group03">group03</option>
                            <option value="group04">group04</option>
                            <option value="group05">group05</option>
                            <option value="group06">group06</option>
                            <option value="group07">group07</option>
                            <option value="group08">group08</option>
                            <option value="group09">group09</option>
                            <option value="group10">group10</option>
                        </select>
                    </div>
                </div>
                <div class="fieldBox col_50">
                    <div class="label">城市</div>
                    <div class="field">
                        <select name="cityCode" id="cityCode">
                            <option value = "1111">全部</option>
                            <c:forEach items="${ctrlList }" var="ct">
                                <option value="${ct.cityCode }">${ct.cityName }</option>
                            </c:forEach>
                        </select>
                    </div>
                </div>
                <div class="fieldBox col_50">
                    <div class="label">金额</div>
                    <div class="field">
                        <select name="amount" id="amount">
                            <option value="1111">--全部--</option>
                            <option value="0-5000">0-5000</option>
                            <option value="5000-15000">5000-10000</option>
                            <option value="10000-15000">10000-15000</option>
                            <option value="15000-20000">15000-20000</option>
                            <option value="20000-30000">20000-30000</option>
                            <option value="30000-50000">30000-50000</option>
                            <option value="50000-9000000">50000以上</option>
                        </select>
                    </div>
                </div>
                 <div class="fieldBox col_50">
                    <div class="label">是否减息</div>
                    <div class="field">
                       <select name="isReduction" id="isReduction">
	                		<option value="1">是</option>
	                		<option value="0">否</option>
	                	</select>
                    </div>
                </div>
                <div class="fieldBox col_50">
                    <div class="label">小贷借款次数(减息)</div>
                    <div class="field">
                        <select name="sLoanNum" id="sLoanNum">
                            <option value="1111">--全部--</option>
                            <option value="0">0</option>
                            <option value="1">1</option>
                            <option value="2">2</option>
                            <option value="3">3</option>
                            <option value="4">4</option>
                            <option value="5">5</option>
                            <option value="6">6</option>
                            <option value="7">7</option>
                            <option value="8">8</option>
                            <option value="9">9</option>
                            <option value="10">10</option>
                            <option value="11">11</option>
                            <option value="12">12</option>
                        </select>
                    </div>
                </div>
                <div class="fieldBox col_50">
                    <div class="label">车贷期数(减息)</div>
                    <div class="field">
                        <select name="vehicleCrpd" id="vehicleCrpd">
                            <option value="1111">--全部--</option>
                            <option value="1">1</option>
                            <option value="2">2</option>
                            <option value="3">3</option>
                            <option value="4">4</option>
                            <option value="5">5</option>
                            <option value="6">6</option>
                            <option value="7">7</option>
                            <option value="8">8</option>
                            <option value="9">9</option>
                            <option value="10">10</option>
                            <option value="11">11</option>
                            <option value="13">13</option>
                            <option value="14">14</option>
                            <option value="15">15</option>
                            <option value="16">16</option>
                            <option value="17">17</option>
                            <option value="18">18</option>
                            <option value="19">19</option>
                            <option value="20">20</option>
                            <option value="21">21</option>
                            <option value="22">22</option>
                            <option value="23">23</option>
                            <option value="24">24</option>
                        </select>
                    </div>
                </div>
                <div class="fieldBox col_50">
                    <div class="label">是否启用</div>
                    <div class="field">
                        <select name="isValid" id="isValid">
                            <option value="1">是</option>
                            <option value="0">否</option>
                        </select>
                    </div>
                </div>
                <div class="fieldBox col_50">
                    <div class="label">贷款日利率%</div>
                    <div class="field">
                        <input name="loanRatePct" id="loanRatePct" type="text" class="ui-textbox" value="" validate="{required:true, maxlength:8, max:0.09}">
                        <span class="requiredSymbol">*</span>
                    </div>
                </div>
                <!-- hide data -->
		        <div class="fieldBox col_100" style="display:none;">
		          <div class="field">
		              <input name="dataId" id="dataId" type="text" class="ui-textbox" value="${id}">
		          </div>
		        </div>
            </div>
        </form>
	<script>
        var nonModify = '${nonModify}';
		$(function() {
		   $("#mcrPrpsRate_form").ligerForm({
                validate: true
           });
            initData();
            if(nonModify == '1'){
                if(liger.get("cstTypeCd")){
                    liger.get("cstTypeCd").setDisabled(true);
                }
                if(liger.get("crTypCd")){
                    liger.get("crTypCd").setDisabled(true);
                }
                if(liger.get("crPd")){
                    liger.get("crPd").setDisabled(true);
                }
                if(liger.get("crLvlCd")){
                    liger.get("crLvlCd").setDisabled(true);
                }
                if(liger.get("cityCode")){
                    liger.get("cityCode").setDisabled(true);
                }
                if(liger.get("isValid")){
                    liger.get("isValid").setDisabled(true);
                }
                if(liger.get("amount")){
                    liger.get("amount").setDisabled(true);
                }
            }
		});
		
		//定义父级调用事件
		frameElement.dialog.onOk = function () {
			save();
		}
		
		frameElement.dialog.onCancel = function () {
			frameElement.dialog.close();
		}
		
		//保存
		function save(){
			var ligerForm = liger.get("mcrPrpsRate_form");
            if (!ligerForm.valid()) {
                UIUtils.alertWarning("有验证信息未通过!");
                return; //验证不通过，不执行以下代码
            }
            var data = ligerForm.getData();
            var dataId = $("#dataId").val();
            var url = '<%=path%>/mcr/mcrPrpsRate/add.do';
            if(StringUtils.isNotEmpty(dataId)){
            	url = '<%=path%>/mcr/mcrPrpsRate/modify.do';
            	data["id"]= dataId;
            }
            AjaxUtils.ajaxPost(url, data, addCallback);
		}
		
		
		//新增回调
		function addCallback(msg){
			if(msg.success == 1){
				 parent.grid.reload();
				 //parent.$.ligerDialog.SQalert({content:'提示内容', SQ_type: "success"});
				 UIUtils.alertSuccess("操作成功!");
				 frameElement.dialog.close();
			 }else{
				 UIUtils.alertError(msg.info);
			 }
		}
		
		//修改初始化数据
		function initData(){
			var dataId = $("#dataId").val();
	    	if(StringUtils.isEmpty(dataId))return;
	    	var _url = '<%=path%>/mcr/mcrPrpsRate/getById.do';
	    	AjaxUtils.ajaxGet(_url, {id:dataId}, initCallback);
    	}
		
		//初始化回调
		function initCallback(msg){
			if(msg.success == 1){
				 setData(msg.data);//设置数据
			 }else{
				 UIUtils.alertError(msg.info);
			 }
		}
		
		//修改时候设置页面数据
	    function setData(data){
	    	var form = new liger.get("mcrPrpsRate_form");
	    	form.setData({
                cstTypeCd:data.cstTypeCd,
                crTypCd:data.crTypCd,
                crPd:data.crPd,
                crLvlCd:data.crLvlCd,
                isValid:data.isValid,
                cityCode:data.cityCode,
                sLoanNum:data.sLoanNum,
                vehicleCrpd:data.vehicleCrpd,
                isReduction:data.isReduction,
                loanRatePct:data.loanRatePct
	    	});
		};
	</script>

</body>
</html>